/**
 * 定义OperationManagerController运维管理模块
 */
(function(window, angular, undefined){
	
	var OperationManagerController = angular.module('water.apps.voc.operationManage.OperationManagerController', ['ui.router','itfreer','waterCommon','OperatorManagerService']);
	OperationManagerController.controller('OperationStationSearchController',function($TaskNavService,$sce,$scope,$itfreerHttp,$itfreer,$compile,$http,$waterDataCommon,$httpData,$queryObj,$wdp,$rootScope,$viewData,$state){
      $queryObj.QueryStationObj={};
	  $wdp.viewValue.wwtpDetailParm = {};
	//站点类型
		$scope.stationType = getWaterType();
		 $queryObj.QueryStationObj.STATION_CATEGORY=$scope.stationType;
	  //选择某个站点
		$scope.selectWWTP = function(curRow){
			if(curRow){
				$wdp.viewValue.wwtpDetailParm = {
						STATION_ID:curRow.EXP_NO,
						STATION_NAME:curRow.NAME};
				$scope.STATION_ID = curRow.EXP_NO;
			}
			else{
				$wdp.viewValue.wwtpDetailParm = {
						STATION_ID:"",
						STATION_NAME:""};
				$scope.STATION_ID = "";
			}
		};
	  //查询站点信息
	  $scope.queryList=function(){
		  $waterDataCommon.getPageRows("BC_SITE_INFO","StationList",$queryObj.QueryStationObj,10,1,function(data){
				  $scope.selectWWTP(data.data[0]);
		  });
			
		};
		
		//控制选择任务类型
		$scope.getstationType=function(orgid){
			$scope.stationType=orgid;
			if(orgid!="4"){
				$queryObj.QueryStationObj.STATION_CATEGORY=orgid;
			}
			else{
				$queryObj.QueryStationObj.STATION_CATEGORY="";
			}
			$scope.queryList();
		}
		 $scope.queryList();
		 $scope.waterDataCommon=$waterDataCommon;
	});
	
	//运维管理 - 运维任务
	OperationManagerController.controller('TaskQueryController',function($TaskNavService,$sce,$scope,$itfreerHttp,$itfreer,$compile,$http,$waterDataCommon,$httpData,$queryObj,$wdp,$rootScope,$viewData,$state){
		//去掉视频延迟函数
		if($wdp.timeout){
			clearTimeout($wdp.timeout); 
		}
		$scope.queryObject={};		
		$scope.queryObject.QueryTaskObj={};
		$scope.WWTP_NAME="";
		$scope.STATION_NAME="";
	   
       $("#menuOperation1").bind("click",function(){
    	   $("#taskQueryMain").show();
           $("#taskDetail").hide();
       });
		
		$wdp.viewValue.taskcode="";
		var backname="";
		$scope.needGoback = false;
		$scope.goback = function(){
			$("#validationList").show();
			$("#taskQueryMain").hide();
			$state.go("DataValidationQuarter.Statistics");
			$wdp.viewValue.DataValidationParm=null;
			$scope.needGoback = false;
			
		};
		//处理从有效性审核中跳转过来的情况
		if($wdp.viewValue.DataValidationParm){
			setTimeout(function(){
			var flowType = $wdp.viewValue.DataValidationParm.flowType;
			var startTime = $wdp.viewValue.DataValidationParm.startTime;
			var endTime = $wdp.viewValue.DataValidationParm.endTime;
			var job = $wdp.viewValue.DataValidationParm.job;
			var WWTPID= $wdp.viewValue.DataValidationParm.WWTPID;
			$("#Station li[orgid]").removeClass("selected");
			$("#Station li[orgid='"+flowType+"']").addClass("selected");
			$("#TaskUl li").removeClass("selected");
			$scope.queryObject.QueryTaskObj.start = startTime;
			$scope.queryObject.QueryTaskObj.end = endTime;
			$scope.queryObject.QueryTaskObj.DVJob = job;
			$scope.queryObject.QueryTaskObj.taskstrid = job;
			$scope.queryObject.QueryTaskObj.stationstr = flowType;
			$scope.queryObject.QueryTaskObj.TaskStatusStr="1";
			$scope.queryObject.QueryTaskObj.WWTP_ID=WWTPID;
            $waterDataCommon.getPageRows("/TaskQuery/getTaskList.do","TaskList",$scope.queryObject.QueryTaskObj,8,1,function(d){
            	$wdp.viewValue.DataValidationParm=null;
			});
            $scope.needGoback = true;
			},500);
		}
		
		
		//监听左侧参数变化
		$scope.$on('dataPramChanged', function(event, data) {
			$wdp.viewValue.wwtpDetailParm=data;
			$scope.WWTP_NAME=data.STATION_NAME;
			$scope.STATION_NAME=data.STATION_NAME;
			$scope.STATION_ID = data.STATION_ID;
			
			//if(!$scope.WWTPID && !$scope.STATION_ID) return;
			if(!$scope.STATION_ID) return;
			//$scope.queryObject.QueryTaskObj.WWTP_ID=$wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.queryObject.QueryTaskObj.STATION_ID=data.STATION_ID;
			$scope.getTaskList();
			$("#wsclcname li[orgid='"+1+"']").removeClass('selected');
			$("#wsclcname li[orgid='"+0+"']").addClass('selected');
	    });
		$scope.change=function(str){
			       $wdp.viewValue.taskcode="";
			       $wdp.viewValue.taskshow=false;
			       $("#taskQueryMain").hide();
			       $("#taskDetail").show();
		    	   $state.go(str);
		    };
		$scope.getWsclcname=function(orgid){
			if(orgid=="0"){
				$("#wsclcname li[orgid='"+1+"']").removeClass('selected');
				$("#wsclcname li[orgid='"+0+"']").addClass('selected');
				$scope.queryObject.QueryTaskObj.WWTP_ID=$wdp.viewValue.wwtpDetailParm.WWTPID;	
				$scope.queryObject.QueryTaskObj.STATION_ID=$wdp.viewValue.wwtpDetailParm.STATION_ID;
				
			}
            if(orgid=="1"){
            	$("#wsclcname li[orgid='"+0+"']").removeClass('selected');
            	$("#wsclcname li[orgid='"+1+"']").addClass('selected');
            	$scope.queryObject.QueryTaskObj.STATION_ID="";
            	$scope.queryObject.QueryTaskObj.WWTP_ID="";
			}
		};
		$scope.getOperationGroupData=function(){
			$waterDataCommon.getPageRows("/TaskQuery/getOperatorGroupList.do","groupList",{waterType:getWaterType()},100,1,function(d){
				
			});
		};
		$scope.queryParamJobList=function(data){
			$waterDataCommon.getPageRows("/TaskQuery/getJobList.do","JobList",{job_type:data},100,1);
		}
		$scope.queryParamJobList(getWaterType());
		$scope.getOperationGroupData();
		//选择站点类型
		$scope.stationType = "0";
		//站点类型
		var stationTypestrid=getWaterType();
		$scope.getstationType=function(orgid){
			$scope.stationType=orgid;
			if(orgid!="4"){
				stationTypestrid=orgid;
			}
			else{
				stationTypestrid="";
			}
			$scope.queryParamJobList(orgid);
			
		};
		var groupstrid="";
		//控制选择运维组
		$scope.getGroup=function(orgid){
			var li3 = $("#groupUl li[orgid='"+2+"']");
			if(orgid=="")
			{
				groupstrid="";
				var li1=$("#groupUl li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#groupUl li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(groupstrid.indexOf(orgid) > 0 ){
					groupstrid=groupstrid.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				groupstrid= groupstrid+","+orgid;
			}
			if(!$("#groupUl li").hasClass("selected")){
				li3.addClass('selected');
			}
		};
		var taskstrid="";
		//控制选择运维内容
		$scope.getTask=function(orgid){
			var li3 = $("#TaskUl li[orgid='"+2+"']");
			if(orgid=="")
			{
				taskstrid="";
				var li1=$("#TaskUl li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#TaskUl li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(taskstrid.indexOf(orgid) > 0 ){
					taskstrid=taskstrid.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				taskstrid= taskstrid+","+orgid;
			}
			if(!$("#TaskUl li").hasClass("selected")){
				li3.addClass('selected');
			}
			
		};
		var stationstr="";
		//控制选择监测点
		$scope.getStation=function(orgid){
			var li3 = $("#Station li[orgid='"+2+"']");
			if(orgid=="2")
			{
				stationstr="";
				var li1=$("#Station li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#Station li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(stationstr.indexOf(orgid) > 0 ){
					stationstr=stationstr.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				stationstr= stationstr+","+orgid;
			}
		};
		$scope.taskStatus = [];
		//控制选择任务类型
		$scope.getTaskStatus=function(orgid){
			if(!orgid){
				$scope.taskStatus=[];
				return;
			}
			var idx = $scope.taskStatus.indexOf(orgid);
			if(idx>-1){
				$scope.taskStatus.splice(idx,1);
			}else{
				$scope.taskStatus.push(orgid);
			}
		}
		//获取任务单数据
		$scope.getTaskList=function(){			
			if($scope.checkErr()==false){
				return false;
			}
			$scope.queryObject.QueryTaskObj.groupstrid=groupstrid.replace(/,/,"");
			$scope.queryObject.QueryTaskObj.stationTypestrid=stationTypestrid;
			
			if(taskstrid != ""){
				$scope.queryObject.QueryTaskObj.taskstrid=taskstrid.replace(/,/,"");
			}
			else{
				$scope.queryObject.QueryTaskObj.taskstrid = "";
			}
			$scope.queryObject.QueryTaskObj.stationstr=stationstr.replace(/,/,"");
			$scope.queryObject.QueryTaskObj.TaskStatusStr=$scope.taskStatus.toString();
			$scope.getTaskData();
		};
		//时间验证
		$scope.checkErr = function(){		   
		    if((new Date($scope.queryObject.QueryTaskObj.start.replace(/-/g,"\/"))) > (new Date($scope.queryObject.QueryTaskObj.end.replace(/-/g,"\/")))){
		    	$.messager.alert("提示","开始时间不能大于结束时间");
		      return false;
		    }		 
		  };
		//查询任务单
		$scope.getTaskData=function(){
			$waterDataCommon.getPageRows("/TaskQuery/getTaskList.do","TaskList",$scope.queryObject.QueryTaskObj,8,1,function(d){
			});
		};
		//导出报表
		$scope.exportPdf = function(){
			var queryString =  $waterDataCommon.jsonTostring($scope.queryObject.QueryTaskObj);
			window.open(getBasePath()+'/TaskQuery/outTaskExcel.do?'+queryString);
		}			
		//查看详细记录
		$scope.getDetail=function(taskCode,wwtpid,wsclcname,job_id,staid){
			 $wdp.viewValue.taskcode=taskCode;
			 $wdp.viewValue.WWTPID=wwtpid;
			 $wdp.viewValue.WWTP_NAME=wsclcname;
			 $wdp.viewValue.STATION_ID=staid;
			 $wdp.viewValue.taskshow=true;
			 var JobIdStateMap={
					 "5385ab20-26ee-4fd0-a419-1cd9174a9921":"StandardSubstance",//标准物质更换
					 "21c74765-685e-4a89-a625-0fa8f3668fc5":"StandardVerification",//标准物质核查
					 "167b2c94-4c13-45fd-b796-8c0e4bf3f6b9":"MaterialReplace",//耗材/备件更换
					 "fa3ecf1a-4820-4f9f-b7b7-2553584ee7ba":"DailyInspection",//日常巡检
					 "0bddcd82-73ff-4ee7-85af-491108b7f374":"PeriodicalMaintainance",//定期维护
					 "2bf6c8b1-12c3-496c-8e1b-96b52157e12c":"ExceedComparison",//超标比对
					 "5ed321b7-99ca-4f0b-b81f-008475d0174a":"FailureRepair",//设备故障及维修
					 "0f9faa25-89e4-4ad6-869f-aa1beb70f7bc":"SampleComparison",//水样比对
					 "21c7cb0d-9ea5-46d1-b150-c04151386678":"ArtificialMonitor",//人工监测
					"d8dfaab4-79b5-4ebd-adb5-df65b334c70f":"SiteExamine",//现场考核
					"c1003e3e-0de0-4f5c-8981-13df70211f87":"SupplyWaterDailyInspection",//供水日常巡检
					"16fe2eed-eba1-4b1c-8ece-46a725a5797b":"SupplyWaterPeriodicalMaintainance",//供水定期维护
					"6e0d4a4d-c107-4645-b3b2-1c1068f0251b":"SupplyWaterDataComparison",//供水数据比对
					"10f1b1f0-0ee6-4f9b-a3df-d36bece12b52":"SupplyWaterExceptionHandling",//供水异常处理
					"6497815d-3e57-4b56-b8c7-7e3ebfbc7e3e":"SupplyWaterMaterialReplace",//供水耗材/备件更换
					"e1fc59ca-63ea-4809-b95d-e7e0226705b2":"DailyInspection",//地表水日常巡检
					"2c8997f4-c12c-424e-b1c8-71d516c412fc":"PeriodicalMaintainance",//地表水定期维护
					"fa85f7c6-bf85-431e-b1a2-3765224f07ea":"ExceedComparison",//地表水超标比对
					 "c1586161-9422-437c-a095-1885c84f3f69":"SampleComparison",//地表水水样比对
					 "315b468b-93e0-4064-989e-fb9b10cfe823":"StandardVerification",//地表水标准物质核查
					 "263f496f-c27c-4676-87b5-55dbc17f10ef":"FailureRepair",//地表水设备故障及维修
					 "643c6771-ebf6-4213-ace7-ac9cdd842539":"StandardSubstance",//地表水日常校准
					 "6dcde798-0c27-479e-999e-60f9cc132f0b":"MaterialReplace",//地表水耗材/备件更换
					 "D1FED4B608FD4159A8B08BD0C087F6C8":"DailyInspection",//工业废气日常巡检
					 "274DB180F2124646A0E44F19116DB680":"DeviceAjustToStandard",//设备零漂、跨漂校准
					 "C1BB41C4167C4B3C83BC2B523579CD60":"DeviceCheck",//设备校验
					 "CA442C572FD741F1AD81C380F2819DE1":"DeviceRepair",//设备维修
					 "6D3F17BC75E940DCA0A0E5E97DCC53A6":"EasyComsumedChange",//易耗品更换
					 "13FCE34AC03E471D868531761B13A1F7":"StardardMateriaExchange",//标准物质更换
					 
					 
			 };
			 var stateName = $state.current.name.replace(".blank","").replace(".bank","");
			 $state.go(stateName+"."+JobIdStateMap[job_id]);
			 $("#taskQueryMain").hide();
			 $("#taskDetail").show();				 
		};
		//查看异常详情
		$scope.getExceptionDetail=function(taskCode){
			$wdp.viewValue.taskcode=taskCode;
			$state.go('operationManager.TaskQuery.DataAnormal');
			$("#taskQueryMain").hide();
			$("#taskDetail").show();
		};
		$scope.waterDataCommon=$waterDataCommon;
		$scope.NavService = $TaskNavService;
    });
	
	/**
	 * 标准物质更换//日常校准
	 */
	OperationManagerController.controller('StandardSubstanceController',function(OperationStationJobService,$TaskNavService,$sce,$scope,$itfreerHttp,$itfreer,$compile,$http,$waterDataCommon,$httpData,$queryObj,$wdp,$rootScope,$viewData,$state){
		$scope.WWTP_NAME="";
		$scope.STATION_NAME="";
		
		$scope.queryObject={};
		$scope.queryObject.QuerySubstanceObj={};   
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			$scope.WWTP_NAME=$wdp.viewValue.wwtpDetailParm.WWTP_NAME;
			$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.STATION_NAME=$wdp.viewValue.STATION_NAME;
			$scope.STATION_ID = $wdp.viewValue.STATION_ID;
			$scope.taskcode=$wdp.viewValue.taskcode;
			if(!$scope.WWTPID && !$scope.STATION_ID) return;
			$scope.queryObject.QuerySubstanceObj.WWTP_ID=$wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.queryObject.QuerySubstanceObj.STATION_ID=$wdp.viewValue.STATION_ID;
			$scope.getSubstanceList();
        },true);
		
		$scope.BackTOTask=function(){
		   $("#taskQueryMain").show();
		   $("#taskDetail").hide();
		   $state.go("operationManager.TaskQuery.blank");
		};
       $scope.getWsclcname=function(orgid){
			if(orgid=="0"){
				$("#wsclcname li[orgid='"+1+"']").removeClass('selected');
				$("#wsclcname li[orgid='"+0+"']").addClass('selected');
				if($wdp.viewValue.taskshow)
				{
					$scope.queryObject.QuerySubstanceObj.WWTP_ID=$wdp.viewValue.WWTPID
				}
				else{
					$scope.queryObject.QuerySubstanceObj.WWTP_ID=$wdp.viewValue.wwtpDetailParm.WWTPID;	
				}
				
			}
            if(orgid=="1"){
            	$("#wsclcname li[orgid='"+0+"']").removeClass('selected');
            	$("#wsclcname li[orgid='"+1+"']").addClass('selected');
            	$scope.queryObject.QuerySubstanceObj.WWTP_ID="";
				$wdp.viewValue.wwtpDetailParm = {};
			}
		};
				
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
		
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
		
		$scope.getSubstanceList=function(){
			$scope.queryObject.QuerySubstanceObj.FLOW_TYPE = $scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE == 'allType'){
				delete $scope.queryObject.QuerySubstanceObj.FLOW_TYPE;
			}
			if($scope.taskcode){
				$scope.queryObject.QuerySubstanceObj.taskcode=$scope.taskcode;
			}
			else{
				$scope.queryObject.QuerySubstanceObj.taskcode=$wdp.viewValue.taskcode;
				$scope.taskcode=$wdp.viewValue.taskcode;
			}
			$scope.taskshow=$wdp.viewValue.taskshow;
			if($scope.taskshow==false){
				$scope.WWTP_NAME=$wdp.viewValue.wwtpDetailParm.WWTP_NAME;
			}
			else{
				$scope.queryObject.QuerySubstanceObj.WWTP_ID=$wdp.viewValue.wwtpDetailParm.WWTPID;
				$scope.WWTP_NAME=$wdp.viewValue.WWTP_NAME;
			}
			$scope.getSubstancesData();
		};
		//查询标准液更换数据
		$scope.getSubstancesData=function(){
			$waterDataCommon.getPageRows("/TaskQuery/getSubstanceList.do","SubstanceList",$scope.queryObject.QuerySubstanceObj,10,1,function(d){
				if($wdp.viewValue.taskcode){
				}
			});
		};
//		$scope.getSubstanceList();//
		$scope.waterDataCommon = $waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	
	/**
	 * 标样核查
	 */
	OperationManagerController.controller('StandardVerificationController',
			function(DateService,OperationStationJobService,$TaskNavService,$sce,$scope,$itfreerHttp,$itfreer,$compile,$http,$waterDataCommon,$httpData,$queryObj,$wdp,$rootScope,$viewData,$state){
		var now = new Date();
		$scope.WWTP_NAME="";
		$scope.STATION_NAME="";
		$scope.queryObject={};
		$scope.queryObject.QueryVerifitionObj={};  
		$scope.queryObject.QueryVerifitionObj.taskCode = $wdp.viewValue.taskcode;
		$scope.allStationSelected = false;
	    if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			$scope.WWTP_NAME=$wdp.viewValue.wwtpDetailParm.WWTP_NAME;
			$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.STATION_NAME=$wdp.viewValue.STATION_NAME;
			$scope.STATION_ID = $wdp.viewValue.STATION_ID;
			if(!$scope.WWTPID && !$scope.STATION_ID) return;
			$scope.queryObject.QueryVerifitionObj.WWTP_ID=$wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.queryObject.QueryVerifitionObj.STATION_ID=$wdp.viewValue.wwtpDetailParm.STATION_ID;
			$scope.getVeriList();
        },true);
		
		$scope.BackTOTask=function(){
			$("#taskQueryMain").show();
			$("#taskDetail").hide();
			$state.go("operationManager.TaskQuery.blank");
		};
		
		$scope.getWsclcname=function(orgid){
			if(orgid=="0"){
				$("#wsclcname li[orgid='"+1+"']").removeClass('selected');
				$("#wsclcname li[orgid='"+0+"']").addClass('selected');
				$scope.queryObject.QueryVerifitionObj.WWTP_ID=$wdp.viewValue.wwtpDetailParm.WWTPID;	
			}
            if(orgid=="1"){
            	$("#wsclcname li[orgid='"+0+"']").removeClass('selected');
            	$("#wsclcname li[orgid='"+1+"']").addClass('selected');
            	delete $scope.queryObject.QueryVerifitionObj.WWTP_ID;
				$wdp.viewValue.wwtpDetailParm = {};
			}
		};
			
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
			
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
				
		$scope.getVeriList=function(){
			$scope.queryObject.QueryVerifitionObj.WWTP_ID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.queryObject.QueryVerifitionObj.STATION_ID = $wdp.viewValue.STATION_ID;
			$scope.queryObject.QueryVerifitionObj.TASK_CODE=$wdp.viewValue.taskcode;
			if($scope.allStationSelected){
				delete $scope.queryObject.QueryVerifitionObj.WWTP_ID;
			}
			$scope.queryObject.QueryVerifitionObj.FLOW_TYPE=$scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.QueryVerifitionObj.FLOW_TYPE;
			}	
			
			$waterDataCommon.getPageRows("/StandardVerification/getVeriList.do","VerifitionList",$scope.queryObject.QueryVerifitionObj,10,1);
		};
		
		$scope.exportDoc = function(curRow){
			var obj = {};
			obj.TASK_CODE = curRow.TASK_CODE;
			obj.STATION_ID = curRow.STATION_ID;
			obj.STATION_NAME = curRow.STATION_NAME;
			var queryString = $waterDataCommon.jsonTostring(obj);
			window.open(getBasePath()+"/StandardVerification/exportDoc.do?"+queryString);
		}	
		
		$scope.waterDataCommon = $waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	/**
	 * 设备故障及维修
	 */
	OperationManagerController.controller('FailureRepairController', function($stateParams,OperationStationJobService,DateService,$TaskNavService,$sce,$scope,$itfreerHttp,$itfreer,$compile,$http,$waterDataCommon,$httpData,$queryObj,$wdp,$rootScope,$viewData,$state){
		
		var strWwtpIDs = "";		// 污染源ID
		var strDeviceStatus = ""; 	// 设备状态
        var strFailureReason = ""; 	// 故障原因
        var strRepairResult = ""; 	// 维修结果
        var now = new Date();
        
        $scope.queryObject={};
        $scope.queryObject.queryFailureObj={};
        $scope.queryObject.queryFailureObj.TASK_ID = $wdp.viewValue.taskcode;
        $scope.queryObject.queryFailureObj.DEVICE_NUM = $wdp.viewValue.deviceNum;
        $scope.queryObject.queryMaterialObj={};
        $scope.queryObject.queryExceptionObj={};
        
        $scope.fromState = $stateParams.fromState;
       
        $scope.ExceptionData={};
        
        //返回
        $scope.BackTOTask=function(){
        	if($scope.fromState){
        		$state.go($scope.fromState,{stationType:$stateParams.stationType});
            	$scope.selectMenu('menuDevice1');
        	}else{
            	$("#taskQueryMain").show();
            	$("#taskDetail").hide();
            	$state.go("operationManager.TaskQuery.blank");
        	}
		};
		
        //监听污水处理厂改变
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if($wdp.viewValue.wwtpDetailParm){
				strWwtpIDs=$wdp.viewValue.wwtpDetailParm.WWTPID;
				$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
				$scope.STATION_ID = $wdp.viewValue.STATION_ID;
				
				if(!$scope.WWTPID && !$scope.STATION_ID) return;
				
				$scope.getFailureRepairList();
			}	
        },true);
		
		//选择污染源条件
		$scope.chooseWWTP=function(orgid){		
			var li = $("#WwtpIDUL li[orgid='"+orgid+"']");
			var li_other = $("#WwtpIDUL li[orgid!='"+orgid+"']");
					
			li.addClass('selected');
			li_other.removeClass('selected');
			strWwtpIDs = orgid;
		} 
		
		//污染源ID
		$scope.getWwtpIDs=function(orgid){
			var li3 = $("#WwtpIDUL li[orgid='all']");
			if(orgid=="all")
			{
				strWwtpIDs="";
				var li1=$("#WwtpIDUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				$wdp.viewValue.wwtpDetailParm = {};
				return;
			}
			var li = $("#WwtpIDUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strWwtpIDs.indexOf(orgid) > 0 ){
					strWwtpIDs = strWwtpIDs.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strWwtpIDs = strWwtpIDs+","+orgid;
			}		
		};
		
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
		
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
      	
		//在线设备状态
		$scope.getDeviceStatus=function(orgid){
			var li3 = $("#DeviceStatusUL li[orgid='all']");
			if(orgid=="all")
			{
				strDeviceStatus="";
				var li1=$("#DeviceStatusUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#DeviceStatusUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strDeviceStatus.indexOf(orgid) > 0 ){
					strDeviceStatus = strDeviceStatus.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strDeviceStatus = strDeviceStatus+","+orgid;
			}		
		};
		
		//设备故障原因
		$scope.getFailureReason=function(orgid){
			var li3 = $("#FailureReasonUL li[orgid='all']");
			if(orgid=="all")
			{
				strFailureReason="";
				var li1=$("#FailureReasonUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#FailureReasonUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strFailureReason.indexOf(orgid) > 0 ){
					strFailureReason = strFailureReason.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strFailureReason = strFailureReason+","+orgid;
			}		
		};
		
		//故障维修结果
		$scope.getRepairResult=function(orgid){
			var li3 = $("#RepairResultUL li[orgid='all']");
			if(orgid=="all")
			{
				strRepairResult="";
				var li1=$("#RepairResultUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#RepairResultUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strRepairResult.indexOf(orgid) > 0 ){
					strRepairResult = strRepairResult.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strRepairResult = strRepairResult+","+orgid;
			}		
		};
		
		//查询字典项列表
		$scope.queryDomainData=function(strDomainName, queryDataList){
			var queryObj = {"DomainName":strDomainName};
			$waterDataCommon.getPageRows("/FailureRepair/getDataDomain.do",queryDataList,queryObj,100,1);
		}
		
		$scope.queryDomainData("STATION_FLOW_NAME", "FlowNameList");
		$scope.queryDomainData("MONITOR_EQUIPMENT_STATUS", "DeviceStatusList");
		$scope.queryDomainData("OPERATION_FAILURE_REASON", "FailureReasonList");
		$scope.queryDomainData("OPERATION_REPAIR_RESULT", "RepairResultList");
		
		//查询设备故障及处理列表
		$scope.getFailureRepairList = function(){
			if(strWwtpIDs != null){
				$scope.queryObject.queryFailureObj.WWTP_ID=strWwtpIDs.replace(/,/,"");
			}
			else{
				$scope.queryObject.queryFailureObj.WWTP_ID="";
			}
			
			$scope.queryObject.queryFailureObj.FLOW_NAME=$scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.queryFailureObj.FLOW_NAME;
			}
			
			$scope.queryObject.queryFailureObj.STATION_ID=$wdp.viewValue.STATION_ID;	
			$scope.queryObject.queryFailureObj.DEVICE_STATUS=strDeviceStatus.replace(/,/,"");
			$scope.queryObject.queryFailureObj.FAILURE_REASON=strFailureReason.replace(/,/,"");
			$scope.queryObject.queryFailureObj.REPAIR_RESULT=strRepairResult.replace(/,/,"");
			
			$waterDataCommon.getPageRows("/FailureRepair/getFailureRepairList.do", "FailureRepairList",$scope.queryObject.queryFailureObj,10,1);
		};
		
		//查询故障设备异常信息
		$scope.queryFailureException=function(failure){
			$wdp.viewValue.taskcode=failure.TASK_ID;
			$state.go('operationManager.TaskQuery.DataAnormal');
			$("#taskQueryMain").hide();
			$("#taskDetail").show();
		}
		
		//查询设备耗材/部件更换记录
		$scope.queryPartMaterialList=function(failure){
			$wdp.viewValue.taskcode=failure.TASK_ID;
			$state.go('operationManager.TaskQuery.MaterialReplace');
			$("#taskQueryMain").hide();
			$("#taskDetail").show();
		}
		
		$scope.exportDoc = function(curRow){
			var obj = {};
			obj.TASK_ID = curRow.TASK_ID;
			obj.STATION_ID = curRow.STATION_ID;
			obj.STATION_NAME = curRow.STATION_NAME;
			var queryString = $waterDataCommon.jsonTostring(obj);
			window.open(getBasePath()+'/FailureRepair/exportDoc.do?'+queryString);
		}
		$scope.waterDataCommon = $waterDataCommon;	
		$scope.NavService = $TaskNavService;
		$("#taskQueryMain").hide();
	    $("#taskDetail").show();
	});
	
	/**
	 * 部件及耗材更换
	 */
	OperationManagerController.controller('MaterialReplaceController', function(OperationStationJobService,DateService,$TaskNavService,$sce,$scope,$itfreerHttp,$itfreer,$compile,$http,$waterDataCommon,$httpData,$queryObj,$wdp,$rootScope,$viewData,$state){
	      
		var strWwtpIDs = "";		// 污染源ID
        var strMaterialName = ""; // 耗材名称
        var now = new Date();
        
        $scope.queryObject={};
        $scope.queryObject.queryMaterialObj={};
        $scope.queryObject.queryMaterialObj.TASK_ID = $wdp.viewValue.taskcode;
		
		//返回
        $scope.BackTOTask=function(){
        	$("#taskQueryMain").show();
        	$("#taskDetail").hide();
        	$state.go("operationManager.TaskQuery.blank");
		}; 
		
		//监听污水处理厂改变
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if($wdp.viewValue.wwtpDetailParm){
				strWwtpIDs=$wdp.viewValue.wwtpDetailParm.WWTPID;
				$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
				$scope.STATION_ID = $wdp.viewValue.wwtpDetailParm.STATION_ID;
				if(!$scope.WWTPID && !$scope.STATION_ID) return;
				$scope.getMaterialReplaceList();
			}	
        },true);
		
		//选择污染源条件
		$scope.chooseWWTP=function(orgid){		
			var li = $("#WwtpIDUL li[orgid='"+orgid+"']");
			var li_other = $("#WwtpIDUL li[orgid!='"+orgid+"']");
					
			li.addClass('selected');
			li_other.removeClass('selected');
			strWwtpIDs = orgid;
		} 
		
		//污染源ID
		$scope.getWwtpIDs=function(orgid){
			var li3 = $("#WwtpIDUL li[orgid='all']");
			if(orgid=="all")
			{
				strWwtpIDs="";
				var li1=$("#WwtpIDUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#WwtpIDUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strWwtpIDs.indexOf(orgid) > 0 ){
					strWwtpIDs = strWwtpIDs.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strWwtpIDs = strWwtpIDs+","+orgid;
			}		
		};
		
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
		
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
      	
		//耗材名称
		$scope.getMaterialName=function(orgid){
			var li3 = $("#MaterialNameUL li[orgid='all']");
			if(orgid=="all")
			{
				strMaterialName="";
				var li1=$("#MaterialNameUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#MaterialNameUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strMaterialName.indexOf(orgid) > 0 ){
					strMaterialName = strMaterialName.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strMaterialName = strMaterialName+","+orgid;
			}		
		};
		
		//查询字典项列表
		$scope.queryDomainData=function(strDomainName, queryDataList){
			var queryObj = {"DomainName":strDomainName};
			$waterDataCommon.getPageRows("/MaterialReplace/getDataDomain.do",queryDataList,queryObj,100,1);
		}
		
		$scope.queryDomainData("STATION_FLOW_NAME", "FlowNameList");
		$scope.queryDomainData("OPERATION_MATERIAL_NAME", "MaterialNameList");
		
		//查询部件/耗材更换记录列表
		$scope.getMaterialReplaceList=function(){
			if(strWwtpIDs != null){
				$scope.queryObject.queryMaterialObj.WWTP_ID=strWwtpIDs.replace(/,/,"");
			}
			else{
				$scope.queryObject.queryMaterialObj.WWTP_ID="";
			}
			$scope.queryObject.queryMaterialObj.FLOW_NAME=$scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.queryMaterialObj.FLOW_NAME;
			}
			$scope.queryObject.queryMaterialObj.STATION_ID= $wdp.viewValue.STATION_ID;
			$scope.queryObject.queryMaterialObj.MATERIAL_NAME=strMaterialName.replace(/,/,"");
			$waterDataCommon.getPageRows("/MaterialReplace/getMaterialReplaceList.do", "MaterialReplaceList",$scope.queryObject.queryMaterialObj,10,1,function(data){
				var d = data.data;
			});
		}
		
		$scope.exportDoc = function(curRow){
			var obj = {};
			obj.TASK_ID = curRow.TASK_ID;
			obj.STATION_ID = curRow.STATION_ID;
			obj.STATION_NAME = curRow.STATION_NAME;
			var queryString = $waterDataCommon.jsonTostring(obj);
			window.open(getBasePath()+"/MaterialReplace/exportDoc.do?"+queryString);
		}	
		
		
		$scope.waterDataCommon = $waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	
	/**
	 * 水样比对
	 */
	OperationManagerController.controller('SampleComparisonController', function(OperationStationJobService,DateService,$TaskNavService,$sce,$scope,$itfreerHttp,$itfreer,$compile,$http,$waterDataCommon,$httpData,$queryObj,$wdp,$rootScope,$viewData,$state){
	     
		var strWwtpIDs = "";			// 污染源ID
        var strMeasureItem = ""; 		// 测量项目
        var strMeasureConclusion = "";	// 测量结论
        var now = new Date();
        
        $scope.queryObject={};
        $scope.queryObject.querySampleObj={};
        $scope.queryObject.querySampleObj.TASK_ID = $wdp.viewValue.taskcode;
		
		//返回
        $scope.BackTOTask=function(){
        	$("#taskQueryMain").show();
        	$("#taskDetail").hide();
        	$state.go("operationManager.TaskQuery.blank");
		};  
		
		//监听污水处理厂改变
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if($wdp.viewValue.wwtpDetailParm){
				strWwtpIDs=$wdp.viewValue.wwtpDetailParm.WWTPID;
				$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
				$scope.STATION_ID = $wdp.viewValue.STATION_ID;
				if(!$scope.WWTPID && !$scope.STATION_ID) return;
				$scope.getSampleComparisonList();
			}	
        },true);
		
		//选择污染源条件
		$scope.chooseWWTP=function(orgid){		
			var li = $("#WwtpIDUL li[orgid='"+orgid+"']");
			var li_other = $("#WwtpIDUL li[orgid!='"+orgid+"']");
					
			li.addClass('selected');
			li_other.removeClass('selected');
			strWwtpIDs = orgid;
		} 
		
		//污染源ID
		$scope.getWwtpIDs=function(orgid){
			var li3 = $("#WwtpIDUL li[orgid='all']");
			if(orgid=="all")
			{
				strWwtpIDs="";
				var li1=$("#WwtpIDUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				$wdp.viewValue.wwtpDetailParm = {};
				return;
			}
			var li = $("#WwtpIDUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strWwtpIDs.indexOf(orgid) > 0 ){
					strWwtpIDs = strWwtpIDs.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strWwtpIDs = strWwtpIDs+","+orgid;
			}		
		};
		
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
		
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
		
		//测量项目
		$scope.getMeasureItem=function(orgid){
			var li3 = $("#MeasureItemUL li[orgid='all']");
			if(orgid=="all")
			{
				strMeasureItem="";
				var li1=$("#MeasureItemUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#MeasureItemUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strMeasureItem.indexOf(orgid) > 0 ){
					strMeasureItem = strMeasureItem.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strMeasureItem = strMeasureItem+","+orgid;
			}		
		};
		
		//测量结论
		$scope.getMeasureConclusion=function(orgid){
			var li3 = $("#MeasureConclusionUL li[orgid='all']");
			if(orgid=="all")
			{
				strMeasureConclusion="";
				var li1=$("#MeasureConclusionUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#MeasureConclusionUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strMeasureConclusion.indexOf(orgid) > 0 ){
					strMeasureConclusion = strMeasureConclusion.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strMeasureConclusion = strMeasureConclusion+","+orgid;
			}		
		};
		
		//查询字典项列表
		$scope.queryDomainData=function(strDomainName, queryDataList){
			var queryObj = {"DomainName":strDomainName};
			$waterDataCommon.getPageRows("/SampleComparison/getDataDomain.do",queryDataList,queryObj,100,1);
		}
		
		$scope.queryDomainData("STATION_FLOW_NAME", "FlowNameList");
		$scope.queryDomainData("MONITOR_PARAM", "MeasureItemList");
		$scope.queryDomainData("OPERATION_COMPARISON_CONCLUSION", "MeasureConclusionList");
		
		//查询水样比对记录列表
		$scope.getSampleComparisonList=function(){
			if(strWwtpIDs != null){
				$scope.queryObject.querySampleObj.WWTP_ID=strWwtpIDs.replace(/,/,"");
			}
			else{
				$scope.queryObject.querySampleObj.WWTP_ID="";
			}
			$scope.queryObject.querySampleObj.FLOW_NAME=$scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.querySampleObj.FLOW_NAME;
			}
			$scope.queryObject.querySampleObj.STATION_ID= $wdp.viewValue.STATION_ID;
			$scope.queryObject.querySampleObj.MEASURE_ITEM=strMeasureItem.replace(/,/,"");
			$scope.queryObject.querySampleObj.MEASURE_PERSON="";
			$scope.queryObject.querySampleObj.MEASURE_CONCLUSION=strMeasureConclusion.replace(/,/,"");
	
			$waterDataCommon.getPageRows("/SampleComparison/getSampleComparisonRcdList.do", "SampleComparisonList",$scope.queryObject.querySampleObj,10,1);
		}
		$scope.exportDoc = function(curRow){
			var obj = {};
			obj.TASK_ID = curRow.TASK_ID;
			obj.STATION_ID = curRow.STATION_ID;
			obj.STATION_NAME = curRow.STATION_NAME;
			var queryString = $waterDataCommon.jsonTostring(obj);
			window.open(getBasePath()+"/SampleComparison/exportDoc.do?"+queryString);
		}
		
		$scope.waterDataCommon = $waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	
	/**
	 * 超标比对
	 */
	OperationManagerController.controller('ExceedComparisonController', function(OperationStationJobService,DateService,$TaskNavService,$sce,$scope,$itfreerHttp,$itfreer,$compile,$http,$waterDataCommon,$httpData,$queryObj,$wdp,$rootScope,$viewData,$state){
	      
		var strWwtpIDs = "";			// 污染源ID
        var strMeasureItem = ""; 		// 测量项目
        var strMeasureConclusion = ""; 	// 测量结论
        var now = new Date();
        
        $scope.queryObject={};
        $scope.queryObject.queryExceedObj={};
        $scope.queryObject.queryExceedObj.TASK_ID = $wdp.viewValue.taskcode;
		
		//返回
        $scope.BackTOTask=function(){
        	$("#taskQueryMain").show();
        	$("#taskDetail").hide();
        	$state.go("operationManager.TaskQuery.blank");
        };
		
		//监听污水处理厂改变
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if($wdp.viewValue.wwtpDetailParm){
				strWwtpIDs=$wdp.viewValue.wwtpDetailParm.WWTPID;
				$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
				$scope.STATION_ID = $wdp.viewValue.STATION_ID;
				
				if(!$scope.WWTPID && !$scope.STATION_ID) return;
				
				$scope.getExceedComparisonList();
			}	
        },true);
		
		//选择污染源条件
		$scope.chooseWWTP=function(orgid){		
			var li = $("#WwtpIDUL li[orgid='"+orgid+"']");
			var li_other = $("#WwtpIDUL li[orgid!='"+orgid+"']");
					
			li.addClass('selected');
			li_other.removeClass('selected');
			strWwtpIDs = orgid;
		} 
		
		//污染源ID
		$scope.getWwtpIDs=function(orgid){
			var li3 = $("#WwtpIDUL li[orgid='all']");
			if(orgid=="all")
			{
				strWwtpIDs="";
				var li1=$("#WwtpIDUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				$wdp.viewValue.wwtpDetailParm = {};
				return;
			}
			var li = $("#WwtpIDUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strWwtpIDs.indexOf(orgid) > 0 ){
					strWwtpIDs = strWwtpIDs.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strWwtpIDs = strWwtpIDs+","+orgid;
			}		
		};
		
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
		
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
		
		//测量项目
		$scope.getMeasureItem=function(orgid){
			var li3 = $("#MeasureItemUL li[orgid='all']");
			if(orgid=="all")
			{
				strMeasureItem="";
				var li1=$("#MeasureItemUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#MeasureItemUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strMeasureItem.indexOf(orgid) > 0 ){
					strMeasureItem = strMeasureItem.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strMeasureItem = strMeasureItem+","+orgid;
			}		
		};
		
		//测量结论
		$scope.getMeasureConclusion=function(orgid){
			var li3 = $("#MeasureConclusionUL li[orgid='all']");
			if(orgid=="all")
			{
				strMeasureConclusion="";
				var li1=$("#MeasureConclusionUL li");
				li1.removeClass('selected');
				li3.addClass('selected');
				return;
			}
			var li = $("#MeasureConclusionUL li[orgid='"+orgid+"']");
			if(li.hasClass("selected"))
			{
				li3.removeClass('selected');
				li.removeClass('selected');
				if(strMeasureConclusion.indexOf(orgid) > 0 ){
					strMeasureConclusion = strMeasureConclusion.replace(","+orgid,"");
				}
			}
			else{
				li3.removeClass('selected');
				li.addClass('selected');
				strMeasureConclusion = strMeasureConclusion+","+orgid;
			}		
		};
		
		//查询字典项列表
		$scope.queryDomainData=function(strDomainName, queryDataList){
			var queryObj = {"DomainName":strDomainName};
			$waterDataCommon.getPageRows("/ExceedComparison/getDataDomain.do",queryDataList,queryObj,100,1);
		}
		
		$scope.queryDomainData("STATION_FLOW_NAME", "FlowNameList");
		$scope.queryDomainData("MONITOR_PARAM", "MeasureItemList");
		$scope.queryDomainData("OPERATION_COMPARISON_CONCLUSION", "MeasureConclusionList");
		
		//查询超标比对记录列表
		$scope.getExceedComparisonList=function(){
			if(strWwtpIDs != null){
				$scope.queryObject.queryExceedObj.WWTP_ID=strWwtpIDs.replace(/,/,"");
			}
			else{
				$scope.queryObject.queryExceedObj.WWTP_ID="";
			}
			
			$scope.queryObject.queryExceedObj.FLOW_NAME=$scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.queryExceedObj.FLOW_NAME;
			}
			$scope.queryObject.queryExceedObj.STATION_ID=$wdp.viewValue.wwtpDetailParm.STATION_ID;
			$scope.queryObject.queryExceedObj.MEASURE_ITEM=strMeasureItem.replace(/,/,"");
			$scope.queryObject.queryExceedObj.MEASURE_PERSON="";
			$scope.queryObject.queryExceedObj.MEASURE_CONCLUSION=strMeasureConclusion.replace(/,/,"");
	
			$waterDataCommon.getPageRows("/ExceedComparison/getExceedComparisonList.do", "ExceedComparisonList",$scope.queryObject.queryExceedObj,10,1);
		}
		
		$scope.exportDoc = function(curRow){
			var obj = {};
			obj.TASK_ID = curRow.TASK_ID;
			obj.STATION_ID = curRow.STATION_ID;
			obj.STATION_NAME = curRow.STATION_NAME;
			var queryString = $waterDataCommon.jsonTostring(obj);
			window.open(getBasePath()+"/ExceedComparison/exportDoc.do?"+queryString);
		}
		
		
		$scope.waterDataCommon = $waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	
	
	/**
	 * 日常巡检-污水厂
	 */
	OperationManagerController.controller("DailyInspectionController",function(DateService,$TaskNavService,$state,$rootScope,$itfreer_core,$itfreerHttp,$wdp,$scope,OperationStationJobService,$waterDataCommon){
		$scope.WWTP_NAME="";
		$scope.STATION_NAME="";
		$scope.queryObject={};
		$scope.queryObject.TASK_CODE = $wdp.viewValue.taskcode;
		var now = new Date();
		$scope.choseAllStation = function(){
			$scope.allStationSelected = true;
			$wdp.viewValue.wwtpDetailParm = {};
		}
		
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			$scope.allStationSelected = false;
			$scope.WWTP_NAME=$wdp.viewValue.wwtpDetailParm.WWTP_NAME;
			$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.STATION_NAME=$wdp.viewValue.STATION_NAME;
			$scope.STATION_ID = $wdp.viewValue.STATION_ID;
			
			if(!$scope.WWTPID && !$scope.STATION_ID) return;
			
			$scope.getDailyInspectionList();
        },true);
		
		$scope.getDailyInspectionList=function(){
			$scope.queryObject.WWTP_ID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.queryObject.STATION_ID = $wdp.viewValue.STATION_ID;
			if($scope.allStationSelected){
				delete $scope.queryObject.WWTP_ID;
				delete $scope.queryObject.STATION_ID;
			}
			$scope.queryObject.FLOW_TYPE=$scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.FLOW_TYPE;
			}	
			
			$scope.queryObject.PITEM_NAME=$scope.selectedInspectionType.S_DOMAINCAPTION;
			if($scope.selectedInspectionType.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.PITEM_NAME;
			}	
			if($wdp.viewValue.taskcode){
				$scope.queryObject.TASK_CODE=$wdp.viewValue.taskcode;
			}
			$waterDataCommon.getPageRows("/WasteGasDailyInspection/geDailyInspectionList.do","DailyInspectionList",$scope.queryObject,20,1,function(d){
				$scope.hasException=false;
				/*OperationStationJobService.postQuery("/Exception/getExceptionCount.do",{taskCode:$scope.curTask.TASK_CODE}).then(function(data){
					if(data && data.count>0){
						$scope.hasException=true;
					}
				});*/
			});
		};
		
		$scope.exportDoc = function(curRow){
			var queryString =  $waterDataCommon.jsonTostring({'TASK_CODE':curRow.TASK_CODE});
			window.open(getBasePath()+'/DailyInspection/exportDoc.do?'+queryString);
		}
		
		$scope.filterByInspectionType = function(){
			$scope.getDailyInspectionList();
		}
		
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
		
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
		
		$scope.dailyInspectionType=[];
		$scope.selectedInspectionType={'S_DOMAINCODE':'allType','S_DOMAINCAPTION':'全部','selected':true};
		OperationStationJobService.postQuery("/WasteGasDailyInspection/getInspectionItems.do",{}).then(function(data){
			$scope.dailyInspectionType=[];
			angular.forEach(data,function(value,key){
				$scope.dailyInspectionType.push({'S_DOMAINCODE':value.code,'S_DOMAINCAPTION':value.name,'selected':false});
			});
			$scope.dailyInspectionType.splice(0,0,{'S_DOMAINCODE':'allType','S_DOMAINCAPTION':'全部','selected':true})
		});
		$scope.toggleInspectionType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedInspectionType=row;
			angular.forEach($scope.dailyInspectionType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
			
			$scope.filterByInspectionType();
		}
		
		$scope.hasException=false;
		$scope.showException=function(){
			$wdp.viewValue.taskcode=$scope.curTask.TASK_CODE;
			$state.go('operationManager.TaskQuery.DataAnormal');
			$("#taskQueryMain").hide();
			$("#taskDetail").show();
		}
		
		$scope.BackTOTask=function(){
			$TaskNavService.BackToTask();
		};
		
		$scope.waterDataCommon=$waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	
	/**
	 * 定期维护--污水厂
	 */
	OperationManagerController.controller("PeriodicalMaintainanceController",function(DateService,$TaskNavService,$state,$rootScope,$wdp,$scope,OperationStationJobService,$waterDataCommon){
		$scope.WWTP_NAME="";
		$scope.STATION_NAME="";
		$scope.queryObject={};
		$scope.queryObject.taskCode = $wdp.viewValue.taskcode;
		var now = new Date();
		$scope.choseAllStation = function(){
			$scope.allStationSelected = true;
			$wdp.viewValue.wwtpDetailParm = {};
		}
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			$scope.allStationSelected = false;
			$scope.WWTP_NAME=$wdp.viewValue.wwtpDetailParm.WWTP_NAME;
			$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.STATION_NAME=$wdp.viewValue.STATION_NAME;
			$scope.STATION_ID = $wdp.viewValue.STATION_ID;
			
			if(!$scope.WWTPID && !$scope.STATION_ID) return;
			$scope.gePeroidMaintainanceList();
        },true);
		
		$scope.gePeroidMaintainanceList=function(){
			$scope.queryObject.WWTP_ID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.queryObject.STATION_ID = $wdp.viewValue.STATION_ID;
			
			if($scope.allStationSelected){
				delete $scope.queryObject.WWTP_ID;
				delete $scope.queryObject.STATION_ID;
			}
			$scope.queryObject.FLOW_TYPE=$scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.FLOW_TYPE;
			}	
			
			$scope.queryObject.PITEM_NAME=$scope.selectedMaintainanceType.S_DOMAINCAPTION;
			if($scope.selectedMaintainanceType.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.PITEM_NAME;
			}	
			$scope.queryObject.S_DOMAINNAME="运维项";
			$waterDataCommon.getPageRows("/PeroidMaintainance/getPeroidMaintainanceList.do","PeriodMaintainanceList",$scope.queryObject,100,1,function(d){
//				$scope.hasException=false;
//				OperationStationJobService.postQuery("/Exception/getExceptionCount.do",{taskCode:$scope.curTask.TASK_CODE}).then(function(data){
//					if(data && data.count>0){
//						$scope.hasException=true;
//					}
//				});
			});
		};
		
		$scope.filterByMaintainanceType = function(){
			$scope.gePeroidMaintainanceList();
		}
		
		$scope.exportDoc = function(curRow){
			var queryString =  $waterDataCommon.jsonTostring({taskCode:curRow.TASK_CODE,S_DOMAINNAME:"供水运维项"});
			window.open(getBasePath()+'/PeroidMaintainance/exportDoc.do?'+queryString);
		}
		
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
		
		$scope.peroidicalMaintainanceType=[];
		$scope.selectedMaintainanceType={'S_DOMAINCODE':'allType','S_DOMAINCAPTION':'全部','selected':true};
		OperationStationJobService.postQuery("/PeroidMaintainance/getMaintainanceItems.do",{}).then(function(data){
			$scope.peroidicalMaintainanceType=[];
			angular.forEach(data,function(value,key){
				$scope.peroidicalMaintainanceType.push({'S_DOMAINCODE':value.code,'S_DOMAINCAPTION':value.name,'selected':false});
			});
			$scope.peroidicalMaintainanceType.splice(0,0,{'S_DOMAINCODE':'allType','S_DOMAINCAPTION':'全部','selected':true})
		});
		$scope.toggleMaintainanceType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedMaintainanceType=row;
			angular.forEach($scope.peroidicalMaintainanceType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
			
			$scope.filterByMaintainanceType();
		}
		
		$scope.BackTOTask=function(){
			$TaskNavService.BackToTask();
		};
		
		$scope.waterDataCommon=$waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	
	/**
	 * 人工监测
	 */
	OperationManagerController.controller('ArtificialMonitorController',
		function($TaskNavService,$sce,$scope,$itfreerHttp,$itfreer,$compile,$http,$waterDataCommon,$httpData,$queryObj,$wdp,$rootScope,$viewData,$state){
	    $scope.queryObject={};
	    $scope.queryObject.QueryArtificialMonitorObj={};   
	    $scope.BackTOTask=function(){
	    	$TaskNavService.BackToTask();
	    };
	    $scope.ArtificialMonitor=function(){
			$waterDataCommon.getPageRows("/TaskQuery/getArtificialMonitorList.do","ArtificialMonitorList",$scope.queryObject.QueryArtificialMonitorObj,10,1,function(d){
				
			});
		};
		$scope.ArtificialMonitor();
		$scope.waterDataCommon = $waterDataCommon;
		$scope.NavService = $TaskNavService;
	});

	/**
	 * 异常处置
	 */
	OperationManagerController.controller('DataAnormalController',	function($stateParams,$itfreerHttp,UploadService,DateService,$TaskNavService,$state,$scope,$waterDataCommon,$wdp,$rootScope,OperationStationJobService,$state){
		$scope.WWTP_NAME="";
		$scope.STATION_NAME="";
		$scope.queryObject={};
		$scope.queryObject.taskCode = $wdp.viewValue.taskcode;
		var now = new Date();
		$scope.allStationSelected = false;
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		
		$scope.fromState = $stateParams.fromState;
		$scope.alarmId= $wdp.viewValue.ALARM_ID;
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			$scope.WWTP_NAME=$wdp.viewValue.wwtpDetailParm.WWTP_NAME;
			$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.STATION_NAME=$wdp.viewValue.wwtpDetailParm.STATION_NAME;
			$scope.STATION_ID = $wdp.viewValue.wwtpDetailParm.STATION_ID;
			
			if(!$scope.WWTPID && !$scope.STATION_ID) return;
			
			
			$scope.getExceptionList();
        },true);
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
		

		$scope.inProcessing = false;
		$scope.notProcess = false;
		$scope.hasProcessed = false;
		
		$scope.getExceptionList=function(){
			$scope.queryObject.WWTP_ID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.queryObject.STATION_ID = $wdp.viewValue.wwtpDetailParm.STATION_ID;
			if($scope.allStationSelected){
				delete $scope.queryObject.WWTP_ID;
				delete $scope.queryObject.STATION_ID;
			}
			
			$scope.queryObject.FLOW_TYPE=$scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.FLOW_TYPE;
			}	
			if($wdp.viewValue.ALARM_ID){
				$scope.queryObject.ALARM_ID = $wdp.viewValue.ALARM_ID;
				$wdp.viewValue.ALARM_ID = null;
			}
			
			var status = '';
			if($scope.inProcessing) status+="2,";
			if($scope.notProcess) status+="0,";
			if($scope.hasProcessed) status+="1,";
			if(status!=''){
				status = status.substr(0,status.length-1);
				$scope.queryObject.STATUS = status;
			}else{
				delete $scope.queryObject.STATUS;
			}
			 $scope.queryObject.taskCode="";
			$waterDataCommon.getPageRows("/Exception/getAlarmProcessList.do","ExceptionList",$scope.queryObject,10,1,function(r){
				if(r && r.data){
					angular.forEach(r.data,function(value,key){
						value.STATUS_NAME = value.STATUS=='0'?'未处理':(value.STATUS=='1'?'已处理':'处理中')
					});
				}
			});
		};
		
		//导出报表
		$scope.exportDoc = function(curRow){
			var obj = {};
			obj.taskCode = curRow.TASK_CODE;
			obj.STATION_ID = curRow.STATION_ID;
			obj.STATION_NAME = curRow.NAME;
			var queryString =  $waterDataCommon.jsonTostring(obj);
			window.open(getBasePath()+'/Exception/exportDoc.do?'+queryString);
		}
		
		$scope.canUpload = function(curRow){
			return true;
			/*if(curRow.ALARM_TYPE=='02'
				|| curRow.ALARM_TYPE=='03'||curRow.ALARM_TYPE=='06')
				return true;
			
			
			if(curRow.ALARM_TYPE=='04' && 
					curRow.REASON_CODE=='05')
				return true;
			return false;*/
		}
		
		$scope.canDownload = function(curRow){
			if($scope.canUpload(curRow)){
				if(curRow.REPORT){
					return true;
				}
			}
			return false;
		}
		//上传报告
		$scope.uploadDoc = function(curRow){
			UploadService.upload(function(file){
				if(file && file.file){
					curRow.REPORT = file.file;
					$itfreerHttp.save('operation_alarm_process',curRow,function(onSuccess){
						if(onSuccess){
							$.messager.alert("提示","上传成功","info");
							$scope.getExceptionList();
						}
					},function(onerror){
						if(onerror){
							$.messager.alert("提示","上传失败","info");
						}
					}
				 );
				}
			});
		}
		
		//下载报告
		$scope.downloadDoc = function(curRow){
			var fileInfo = curRow.REPORT;
			if (!fileInfo) return;
			fileInfoArr = fileInfo.split(":");
			var url = fileInfoArr[0];
			var name = fileInfoArr[1];
			var downloadUrl = getBasePath()+'/plupload/download.do';
			var _downloadUrl = downloadUrl+"?filePath="+url.replace(getBasePath()+"/","")+"&fileName="+encodeURIComponent(name);
			window.open(_downloadUrl);
		}
		
		//查看任务记录
		$scope.viewTaskRecord = function(curRow){
			if(curRow.JOB_NAME=="设备故障及维修"){
				$wdp.viewValue.taskcode = curRow.TASK_CODE;
				$state.go("operationManager.TaskQuery.FailureRepair");
			}else if(curRow.JOB_NAME=="耗材及备件更换"){
				$wdp.viewValue.taskcode = curRow.TASK_CODE;
				$state.go("operationManager.TaskQuery.MaterialReplace");
			}else if(curRow.JOB_NAME=="标准物质更换"){
				$wdp.viewValue.taskcode = curRow.TASK_CODE;
				$state.go("operationManager.TaskQuery.StandardSubstance");
			}
		}
			
		$scope.BackTOTask=function(){
			if($scope.fromState){
				$state.go($scope.fromState);
				$scope.selectMenu('menuAlarmInfo1');
			}else{
				$("#taskQueryMain").show();
				$("#taskDetail").hide();
				$state.go("operationManager.TaskQuery.blank");
			}
		};
		   
		$scope.waterDataCommon = $waterDataCommon;
		$scope.NavService = $TaskNavService;
		
		$("#taskQueryMain").hide();
	    $("#taskDetail").show();
	});
	/**
	 * 现场考核
	 */
	OperationManagerController.controller("SiteExamineController",function($TaskNavService,$state,$rootScope,$wdp,$scope,OperationStationJobService,$waterDataCommon){
		$scope.WWTP_NAME="";
		$scope.STATION_NAME="";
		$scope.queryObject={};
		$scope.allStationSelected = false;
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			$scope.allStationSelected = false;
			$scope.WWTP_NAME=$wdp.viewValue.wwtpDetailParm.WWTP_NAME;
			$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.STATION_NAME=$wdp.viewValue.STATION_NAME;
			$scope.STATION_ID = $wdp.viewValue.STATION_ID;
			if(!$scope.WWTPID && !$scope.STATION_ID) return;
			$scope.getSiteExamineList();
        },true);
		$scope.choseAllStation = function(){
			$scope.allStationSelected = true;
			$wdp.viewValue.wwtpDetailParm = {};
		}
		$scope.filteredDisplayList=[];
		$scope.displayList=[];
		$scope.getSiteExamineList=function(){
			$scope.queryObject.WWTP_ID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.queryObject.STATION_ID = $wdp.viewValue.STATION_ID;
			if($scope.allStationSelected){
				delete $scope.queryObject.WWTP_ID;
				delete $scope.queryObject.STATION_ID;
			}
			$scope.queryObject.FLOW_TYPE=$scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.FLOW_TYPE;
			}	
			
			$scope.queryObject.GROUP_ID=$scope.selectedGroup.GROUP_ID;
			if($scope.selectedGroup.GROUP_ID=='all'){
				delete $scope.queryObject.GROUP_ID;
			}	
			
			$waterDataCommon.getPageRows("/SiteExamine/getSiteExamineList.do", 
					"SiteExamineList",$scope.queryObject,20,1);
		};
		
		$scope.openExamineDetail=function(row){
			process2(row);
			$itfreer.openWindow('examineDetail');
		}
		
		function process(o){
			$scope.displayList=[];
			
			$scope.displayList.push(getRecord('A01',o.A01,'站房环境','门锁状况',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('A02',o.A02,'站房安全','门禁状况',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('A03',o.A03,'站房安全','窗户状况',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('A04',o.A04,'站房安全','采样头铅封状况',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			
			$scope.displayList.push(getRecord('B01',o.B01,'站房环境','地面清洁',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('B02',o.B02,'站房环境','仪器及仪表柜清洁',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('B03',o.B03,'站房环境','洗手盆、桌及空调清洁',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('B04',o.B04,'站房环境','系统管路、采样杯及流通池清洁情况',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			
			
			$scope.displayList.push(getRecord('C01',o.C01,'物品摆放','废液桶、废液瓶摆放情况',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('C02',o.C02,'物品摆放','制度牌悬挂情况',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('C03',o.C03,'物品摆放','记录本摆放情况',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			
			$scope.displayList.push(getRecord('D01',o.D01,'仪器设备','定期清洗设备',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('D02',o.D02,'仪器设备','定期校准设备',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('D03',o.D03,'仪器设备','系数及修正设置',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('D04',o.D04,'仪器设备','采样器留样设置及采样瓶完整性',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			
			$scope.displayList.push(getRecord('E01',o.E01,'现场记录','记录完整状态',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('E02',o.E02,'现场记录','记录与实际对应情况',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			$scope.displayList.push(getRecord('E03',o.E03,'现场记录','记录本摆放情况',o.EXAMINER,o.OPERATORS,o.EXAM_DATE,o.NAME,o.FLOW_TYPE));
			
			$scope.filterByExamineType();
		}
		
		function getRecord(key,result,examineType,examineItem,examiner,operators,examineDate,wwtpName,flowType){
			var curRow = {};
			curRow.KEY=key;
			curRow.RESULT=result;
			curRow.RESULT_CAPTION=(result=='1'?'不合格':'合格');
			curRow.EXAMINE_TYPE=examineType;
			curRow.EXAMINE_ITEM=examineItem;
			curRow.EXAMINER = examiner;
			curRow.OPERATORS = operators;
			curRow.EXAMINE_DATE=examineDate;
			curRow.WWTP_NAME=wwtpName;
			curRow.FLOW_TYPE=flowType;
			return curRow;
		}
		
		function process2(o){
			$scope.displayList=[];
			
			$scope.displayList.push(getRecord2(o.A01,'站房安全','门锁状况',o.A_NOTE,o.A_SCORE,4));
			$scope.displayList.push(getRecord2(o.A02,'站房安全','门禁状况'));
			$scope.displayList.push(getRecord2(o.A03,'站房安全','窗户状况'));
			$scope.displayList.push(getRecord2(o.A04,'站房安全','采样头铅封状况'));
			
			$scope.displayList.push(getRecord2(o.B01,'站房环境','地面清洁',o.B_NOTE,o.B_SCORE,4));
			$scope.displayList.push(getRecord2(o.B02,'站房环境','仪器及仪表柜清洁'));
			$scope.displayList.push(getRecord2(o.B03,'站房环境','洗手盆、桌及空调清洁'));
			$scope.displayList.push(getRecord2(o.B04,'站房环境','系统管路、采样杯及流通池清洁情况'));
			
			
			$scope.displayList.push(getRecord2(o.C01,'物品摆放','废液桶、废液瓶摆放情况',o.C_NOTE,o.C_SCORE,3));
			$scope.displayList.push(getRecord2(o.C02,'物品摆放','制度牌悬挂情况'));
			$scope.displayList.push(getRecord2(o.C03,'物品摆放','记录本摆放情况'));
			
            $scope.displayList.push(getRecord2(o.D01,'仪器设备','定期清洗设备',o.D_NOTE,o.D_SCORE,4));
			$scope.displayList.push(getRecord2(o.D02,'仪器设备','定期校准设备'));
			$scope.displayList.push(getRecord2(o.D03,'仪器设备','系数及修正设置'));
			$scope.displayList.push(getRecord2(o.D04,'仪器设备','采样器留样设置及采样瓶完整性'));
			
			$scope.displayList.push(getRecord2(o.E01,'现场记录','废液桶、废液瓶摆放情况',o.E_NOTE,o.E_SCORE,3));
			$scope.displayList.push(getRecord2(o.E02,'现场记录','制度牌悬挂情况'));
			$scope.displayList.push(getRecord2(o.E03,'现场记录','记录本摆放情况'));
			
			$scope.filterByExamineType();
		}
		
		function getRecord2(result,examineType,examineItem,note,score,rowSpan){
			var curRow = {};
			curRow.RESULT = result;
			curRow.RESULT_CAPTION=(result=='1'?'不合格':'合格');
			curRow.EXAMINE_TYPE=examineType;
			curRow.EXAMINE_ITEM=examineItem;
			curRow.SCORE = score;
			curRow.NOTE=note;
			curRow.ROWSPAN=rowSpan||1;
			return curRow;
		}
		
		$scope.filterByExamineType = function(){
			$scope.filteredDisplayList=[];
			if($scope.selectedExamineType.name=='全部'){
				$scope.filteredDisplayList=$scope.displayList;
			}
			else{
				angular.forEach($scope.displayList,function(value,key){
					if(value.EXAMINE_TYPE==$scope.selectedExamineType.name){
						$scope.filteredDisplayList.push(value);
					}
				});
			}
		}
		
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
		
		$scope.groups = [];
		$scope.selectedGroup={GROUP_ID:'all',GROUP_NAME:'全部',selected:true};
		$scope.getGroups = function(station){
			var qo = {};
			if(station && station!='all'){
				qo.station=station;
			}
			OperationStationJobService.postQuery("/Operation/getGroups.do",qo).then(function(data){
				angular.forEach(data.data,function(value,key){
					value.selected=false;
				});
				$scope.groups =  data.data;
				$scope.groups.splice(0,0,$scope.selectedGroup)
			});
		}
		$scope.getGroups('all');
		
		$scope.toggleGroup = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedGroup=row;
			angular.forEach($scope.groups,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
		
		$scope.examineType=[{name:'全部',selected:true},{name:'站房环境'},{name:'站房清洁'},{name:'物品摆放'},{name:'仪器设备'},{name:'现场记录'}];
		$scope.selectedExamineType={name:'全部',selected:true};
		$scope.toggleExamineType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedExamineType=row;
			angular.forEach($scope.examineType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
			
			$scope.filterByExamineType();
		}
		
		$scope.BackTOTask=function(){
			$TaskNavService.BackToTask();
		};
		$scope.waterDataCommon=$waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	/**
	 * 供水日常巡检
	 */
	OperationManagerController.controller("SupplyWaterDailyInspectionController",function(DateService,$TaskNavService,$state,$rootScope,$itfreer_core,$itfreerHttp,$wdp,$scope,OperationStationJobService,$waterDataCommon){
		$scope.WWTP_NAME="";
		$scope.STATION_NAME="";
		$scope.queryObject={};
		$scope.queryObject.TASK_CODE = $wdp.viewValue.taskcode;
		var now = new Date();
		$scope.choseAllStation = function(){
			$scope.allStationSelected = true;
			$wdp.viewValue.wwtpDetailParm = {};
		}
		
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			$scope.allStationSelected = false;
			$scope.WWTP_NAME=$wdp.viewValue.wwtpDetailParm.WWTP_NAME;
			$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.STATION_NAME=$wdp.viewValue.WWTP_NAME;
			$scope.STATION_ID = $wdp.viewValue.STATION_ID;
			
			if(!$scope.WWTPID && !$scope.STATION_ID) return;
			
			$scope.getDailyInspectionList();
        },true);
		
		$scope.getDailyInspectionList=function(){
			$scope.queryObject.WWTP_ID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.queryObject.STATION_ID = $wdp.viewValue.STATION_ID;
			if($scope.allStationSelected){
				delete $scope.queryObject.WWTP_ID;
				delete $scope.queryObject.STATION_ID;
			}
			$scope.queryObject.FLOW_TYPE=$scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.FLOW_TYPE;
			}	
			
			$scope.queryObject.PITEM_NAME=$scope.selectedInspectionType.S_DOMAINCAPTION;
			if($scope.selectedInspectionType.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.PITEM_NAME;
			}	
			if($wdp.viewValue.taskcode){
				$scope.queryObject.TASK_CODE=$wdp.viewValue.taskcode;
			}
			$waterDataCommon.getPageRows("/DailyInspection/getSupplyWaterDailyInspectionList.do","DailyInspectionList",$scope.queryObject,20,1,function(d){
				$scope.hasException=false;
				
			});
		};
		
		$scope.exportDoc = function(curRow){
			var queryString =  $waterDataCommon.jsonTostring({'TASK_CODE':curRow.TASK_CODE});
			window.open(getBasePath()+'/DailyInspection/exportDoc.do?'+queryString);
		}
		
		$scope.filterByInspectionType = function(){
			$scope.getDailyInspectionList();
		}
		
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
		
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
		
		$scope.dailyInspectionType=[];
		$scope.selectedInspectionType={'S_DOMAINCODE':'allType','S_DOMAINCAPTION':'全部','selected':true};
		OperationStationJobService.postQuery("/DailyInspection/getSupplyWaterInspectionItems.do",{}).then(function(data){
			$scope.dailyInspectionType=[];
			angular.forEach(data,function(value,key){
				$scope.dailyInspectionType.push({'S_DOMAINCODE':value.code,'S_DOMAINCAPTION':value.name,'selected':false});
			});
			$scope.dailyInspectionType.splice(0,0,{'S_DOMAINCODE':'allType','S_DOMAINCAPTION':'全部','selected':true})
		});
		$scope.toggleInspectionType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedInspectionType=row;
			angular.forEach($scope.dailyInspectionType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
			
			$scope.filterByInspectionType();
		}
		
		$scope.hasException=false;
		$scope.showException=function(){
			$wdp.viewValue.taskcode=$scope.curTask.TASK_CODE;
			$state.go('operationManager.TaskQuery.DataAnormal');
			$("#taskQueryMain").hide();
			$("#taskDetail").show();
		}
		
		$scope.BackTOTask=function(){
			$TaskNavService.BackToTask();
		};
		
		$scope.waterDataCommon=$waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	
	/**
	 * 定期维护--供水
	 */
	OperationManagerController.controller("SupplyWaterPeriodicalMaintainanceController",function(DateService,$TaskNavService,$state,$rootScope,$wdp,$scope,OperationStationJobService,$waterDataCommon){
		$scope.WWTP_NAME="";
		$scope.STATION_NAME="";
		$scope.queryObject={};
		$scope.queryObject.taskCode = $wdp.viewValue.taskcode;
		var now = new Date();
		$scope.choseAllStation = function(){
			$scope.allStationSelected = true;
			$wdp.viewValue.wwtpDetailParm = {};
		}
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			$scope.allStationSelected = false;
			$scope.WWTP_NAME=$wdp.viewValue.wwtpDetailParm.WWTP_NAME;
			$scope.WWTPID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.STATION_NAME=$wdp.viewValue.STATION_NAME;
			$scope.STATION_ID = $wdp.viewValue.STATION_ID;
			
			if(!$scope.WWTPID && !$scope.STATION_ID) return;
			$scope.gePeroidMaintainanceList();
        },true);
		
		$scope.gePeroidMaintainanceList=function(){
			$scope.queryObject.WWTP_ID = $wdp.viewValue.wwtpDetailParm.WWTPID;
			$scope.queryObject.STATION_ID = $wdp.viewValue.STATION_ID;
			
			if($scope.allStationSelected){
				delete $scope.queryObject.WWTP_ID;
				delete $scope.queryObject.STATION_ID;
			}
			$scope.queryObject.FLOW_TYPE=$scope.selectedStationtype.S_DOMAINCODE;
			if($scope.selectedStationtype.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.FLOW_TYPE;
			}	
			
			$scope.queryObject.PITEM_NAME=$scope.selectedMaintainanceType.S_DOMAINCAPTION;
			if($scope.selectedMaintainanceType.S_DOMAINCODE=='allType'){
				delete $scope.queryObject.PITEM_NAME;
			}	
			
			$scope.queryObject.S_DOMAINNAME="供水运维项";
			$waterDataCommon.getPageRows("/PeroidMaintainance/getPeroidMaintainanceList.do","PeriodMaintainanceList",$scope.queryObject,100,1,function(d){

			});
		};
		
		$scope.filterByMaintainanceType = function(){
			$scope.gePeroidMaintainanceList();
		}
		
		$scope.exportDoc = function(curRow){
			var queryString =  $waterDataCommon.jsonTostring({taskCode:curRow.TASK_CODE,S_DOMAINNAME:"供水运维项"});
			window.open(getBasePath()+'/PeroidMaintainance/exportDoc.do?'+queryString);
		}
		
		$scope.stationType = [];
		$scope.selectedStationtype={S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true};
		OperationStationJobService.postQuery("/Operation/getStationType.do",{}).then(function(data){
			angular.forEach(data.data,function(value,key){
				value.selected=false;
			});
			$scope.stationType =  data.data;
			$scope.stationType.splice(0,0,{S_DOMAINCODE:'allType',S_DOMAINCAPTION:'全部',selected:true})
		});
		$scope.toggleStationType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedStationtype=row;
			angular.forEach($scope.stationType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
		}
		
		$scope.peroidicalMaintainanceType=[];
		$scope.selectedMaintainanceType={'S_DOMAINCODE':'allType','S_DOMAINCAPTION':'全部','selected':true};
		OperationStationJobService.postQuery("/PeroidMaintainance/getSupplyWaterMaintainanceItems.do",{}).then(function(data){
			$scope.peroidicalMaintainanceType=[];
			angular.forEach(data,function(value,key){
				$scope.peroidicalMaintainanceType.push({'S_DOMAINCODE':value.code,'S_DOMAINCAPTION':value.name,'selected':false});
			});
			$scope.peroidicalMaintainanceType.splice(0,0,{'S_DOMAINCODE':'allType','S_DOMAINCAPTION':'全部','selected':true})
		});
		$scope.toggleMaintainanceType = function(row){
			if(row.selected) return;
			row.selected=true;
			$scope.selectedMaintainanceType=row;
			angular.forEach($scope.peroidicalMaintainanceType,function(value,key){
				if(value!=row){
					value.selected=false;
				}
			});
			
			$scope.filterByMaintainanceType();
		}
		
		$scope.BackTOTask=function(){
			$("#taskQueryMain").show();
			$("#taskDetail").hide();
			$state.go("operationManager.TaskQuery.blank");
		};
		
		$scope.waterDataCommon=$waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	/**
	 * 供水-数据比对
	 */
	OperationManagerController.controller("SupplyWaterDataComparisonController",function(DateService,$TaskNavService,$state,$rootScope,$wdp,$scope,OperationStationJobService,$waterDataCommon){
		$scope.queryObject.QueryDataComparisonObj={};
		$scope.queryObject.QueryDataComparisonObj.task_code=$wdp.viewValue.taskcode;
		$scope.queryObject.QueryDataComparisonObj.station_id=$wdp.viewValue.STATION_ID;
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			$scope.queryObject.QueryDataComparisonObj.task_code=$wdp.viewValue.taskcode;
			$scope.queryObject.QueryDataComparisonObj.station_id=$wdp.viewValue.STATION_ID;
			$scope.getDataComparisonData();
        },true);
		$scope.getDataComparisonData=function(){
			$waterDataCommon.getPageRows("/SupplyWaterController/getComparisonData.do","DataComparisonList",$scope.queryObject.QueryDataComparisonObj,10,1,function(d){
				
			});
		};
		
		$scope.BackTOTask=function(){
			$("#taskQueryMain").show();
			$("#taskDetail").hide();
			$state.go("operationManager.TaskQuery.blank");
		};
		$scope.waterDataCommon = $waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	/**
	 * 供水异常处理
	 */
	OperationManagerController.controller("SupplyWaterExceptionHandlingController",function(DateService,$TaskNavService,$state,$rootScope,$wdp,$scope,OperationStationJobService,$waterDataCommon){
		$scope.queryObject.QueryExceptionHandlingObj={};
		$scope.queryObject.QueryExceptionHandlingObj.task_code=$wdp.viewValue.taskcode;
		$scope.queryObject.QueryExceptionHandlingObj.station_id=$wdp.viewValue.STATION_ID;
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			$scope.queryObject.QueryExceptionHandlingObj.task_code=$wdp.viewValue.taskcode;
			$scope.queryObject.QueryExceptionHandlingObj.station_id=$wdp.viewValue.STATION_ID;
			$scope.getDataComparisonData();
        },true);
		$scope.getDataComparisonData=function(){
			$waterDataCommon.getPageRows("/SupplyWaterController/getExceptionHandlingData.do","ExceptionList",$scope.queryObject.QueryExceptionHandlingObj,10,1,function(d){
				
			});
		};
		
		$scope.BackTOTask=function(){
			$("#taskQueryMain").show();
			$("#taskDetail").hide();
			$state.go("operationManager.TaskQuery.blank");
		};
		$scope.waterDataCommon = $waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	/**
	 * 供水耗材/备件更换
	 */
	OperationManagerController.controller("SupplyWaterMaterialReplaceController",function(DateService,$TaskNavService,$state,$rootScope,$wdp,$scope,OperationStationJobService,$waterDataCommon){
		$scope.queryObject.QueryMaterialReplaceObj={};
		$scope.queryObject.QueryMaterialReplaceObj.task_code=$wdp.viewValue.taskcode;
		$scope.queryObject.QueryMaterialReplaceObj.station_id=$wdp.viewValue.STATION_ID;
		if($wdp.viewValue.wwtpDetailParmWatch){
			$wdp.viewValue.wwtpDetailParmWatch();
		}
		$wdp.viewValue.wwtpDetailParmWatch = $rootScope.$watch(function(){return $wdp.viewValue.wwtpDetailParm;},function(){
			if(!$wdp.viewValue.wwtpDetailParm){
				return;
			}
			$scope.queryObject.QueryMaterialReplaceObj.task_code=$wdp.viewValue.taskcode;
			$scope.queryObject.QueryMaterialReplaceObj.station_id=$wdp.viewValue.STATION_ID;
			$scope.getMaterialReplaceList();
        },true);
		$scope.getMaterialReplaceList=function(){
			$waterDataCommon.getPageRows("/SupplyWaterController/getMaterialReplaceData.do","MaterialReplaceList",$scope.queryObject.QueryMaterialReplaceObj,10,1,function(d){
				
			});
		};
		
		$scope.BackTOTask=function(){
			$("#taskQueryMain").show();
			$("#taskDetail").hide();
			$state.go("operationManager.TaskQuery.blank");
		};
		$scope.waterDataCommon = $waterDataCommon;
		$scope.NavService = $TaskNavService;
	});
	/**
	 * 耗材统计
	 */
	OperationManagerController.controller('StatisticsEquipmentController',function($state,
			$scope,$waterDataCommon,$wdp,$rootScope){
		$scope.queryObject={};
		$scope.allStationSelected =true;
		$scope.$on('dataPramChanged', function(event, data) {
			$scope.wwtpReportParm = data;
			$wdp.viewValue.wwtpDetailParm.STATION_ID = data.STATION_ID;
			$scope.StatistisStationList();
	    });
		//获取耗材信息
		$scope.StatistisStationList = function(){
			$scope.queryObject.STATION_ID = $wdp.viewValue.wwtpDetailParm.STATION_ID;
			var waterType = getWaterType();
			$scope.queryObj.WATER_TYPE = waterType;
			if($wdp.viewValue.wwtpDetailParm){
				if($scope.allStationSelected == true){
					delete $scope.queryObject.STATION_ID;
				}
			}
			$waterDataCommon.getPageRows("/MaterialReplace/StatisticsEquipment.do","StatisticsEquipmentList",$scope.queryObject,10,1);		
		}
	});	
	//导航控制器
	OperationManagerController.controller('OperationManagerNavController',function($scope,$waterDataCommon,$httpData,$queryObj,$wdp,$rootScope,$state){
		if($wdp.viewValue.stateWatch){
			$wdp.viewValue.stateWatch();
		}
		$wdp.viewValue.stateWatch = $rootScope.$watch(function(){return $state.current;},function(){
			$scope.stateName = $state.current.name;
        },true);
	});
}(window, angular));